package com.bookstore.service.impl;

import com.bookstore.dao.UserDao;
import com.bookstore.dao.impl.UserDaoImpl;
import com.bookstore.entity.User;
import com.bookstore.service.UserService;

import java.util.Date;

public class UserServiceImpl implements UserService {
    UserDao userDao = new UserDaoImpl();

    @Override
    public int registUser(User user) {
        return userDao.insertUser(user);
    }

    @Override
    public User login(User user) {
        return userDao.queryUserByUsernameAndPassword(user);
    }

    @Override
    public boolean existsUsername(String username) {
        return userDao.queryUserByUsername(username) != null;
    }

    @Override
    public int updateLastLoginTime(Long userId, Date loginTime) {
        return userDao.updateLastLoginTime(userId, loginTime);
    }
}
